package com.mr.sell.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mr.sell.utils.ConstantEnum;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Data
@DynamicUpdate
public class ProductInfo {
    @Id
    @JsonProperty("id")//反馈给前端的名称
    private String productId;
    /*名字*/
    @JsonProperty("name")
    private String productName;
    /*单价*/
    @JsonProperty("price")
    private BigDecimal productPrice;
    /*库存*/
    private int productStock;
    /*描述*/
    @JsonProperty("description")
    private String productDescription;
    /*小图*/
    @JsonProperty("icon")
    private String productIcon;
    /*状态：0正常1下架*/
    private int productStatus = ConstantEnum.PRODUCT_UP.getCode();
    /*类目编号*/
    private int categoryType;
    private Date createTime;
    private Date updateTime;
    @JsonIgnore//转成json时忽略
    public String getProductStatusMessage(){
        return ConstantEnum.getConstantEnum(productStatus);
    }
}
